let box = document.querySelector(".box");
let main=document.querySelector(".main");
let items=document.querySelector(".main>img");
let last=document.querySelector(".last");
let next=document.querySelector(".next");


let curr=5;

next.onclick=function(){
    curr++;
    main.style.left=-curr*980+"px";
    if(curr>=items.length){
        curr=0;
        main.style.left="0px";
    }
}

last.onclick=function(){
    curr--;
    main.style.left=-curr*980+"px";
    if(curr<0){
        curr=items.length-1;
        main.style.left="-3920px";
    }
}
let time=setInterval(() =>{
    next.onclick();
},2000);

box.onmouseenter=function(){
    clearInterval(time);
}
box.onmouseleave=function(){
     time=setInterval(()=>{
        next.onclick();
    },2000);
}